//引入样式
require('../../assets/css/normalize.css')
require('../../assets/css/reset.css')
require('../../assets/fonts/iconfont.css');
require('./sports_course_detail.less');

//引入模块
let axios = require('../../utils/axios.js')
let dom = require('../../utils/dom.js')

document.addEventListener("DOMContentLoaded", function () {
    //获取地址栏传递的参数
    let courseId = Number(location.search.split('=').pop())

    axios.get("/api/train/courseDetail?id=" + courseId).then(res => {
        //获取课程训练信息
        let data = res.data.data
        console.log(data);
        let name = data.name
        let desc = data.desc
        let imgurl = data.imgurl
        let calorie = data.calorie
        let time = data.time
        let instrument = data.instrument
        //渲染课程信息
        dom.get(".name").textContent = name
        dom.get('.desc').textContent = desc
        dom.get('.imageurl').src = "http://fitness.h5.itsource.cn:3701" + imgurl
        dom.get('.calorie').textContent = calorie
        dom.get(".time").textContent = time
        dom.get('.instrument').textContent = instrument
        //将后台的视频文件存储到本地存储中
        localStorage.setItem('fragments', JSON.stringify(data.fragments))
    })

})